package com.qiaoyanqing.ximalaya.discovermodule.discover_adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.qiaoyanqing.ximalaya.R;
import com.qiaoyanqing.ximalaya.discovermodule.discover_entity.DiscoverActivityEntity;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by Administrator on 2016/12/12.
 */

public class DiscoverRecommendActiLVAdapter extends BaseAdapter {
    private List<DiscoverActivityEntity.ResultBean.ActivityDataBean> mData;
    private Context mContext;

    public DiscoverRecommendActiLVAdapter(List<DiscoverActivityEntity.ResultBean.ActivityDataBean> data, Context context) {
        mData = data;
        mContext = context;
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public Object getItem(int i) {
        return mData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder=null;
        if (view == null) {
            holder=new ViewHolder();
            view= LayoutInflater.from(mContext).inflate(R.layout.recoactivityview,viewGroup,false);
            holder.mImageView= (ImageView) view.findViewById(R.id.acimageview);
            holder.mTextView= (TextView) view.findViewById(R.id.actextview);
            view.setTag(holder);
        }else {
             holder= (ViewHolder) view.getTag();

        }

        //
        holder.mTextView.setText(mData.get(i).getTitle());
        Picasso.with(mContext).load(mData.get(i).getCoverPathLarge()).into(holder.mImageView);

        return view;
    }
    static class ViewHolder{
        ImageView mImageView;
        TextView mTextView;
    }

}
